  <!DOCTYPE html>
  <html lang="en">
  <head>
      <meta charset="UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Document</title>
  </head>
  <body>
      <script>
        var VehicleFactory = function(subType,superType){
        if(typeof VehicleFactory[superType] === 'function'){
                    //创建一个过渡类
                function f (){}
                //为什么要用new
                f.prototype = new VehicleFactory[superType]
                subType.constructor = subType
                subType.prototype = new F()
                }else{
                    return new Error('没有这个抽象类，可以用点语法')
                }
              

        }
          VehicleFactory.student = function(stuid,stuname){
              this.type = 'student'
          }
          VehicleFactory.student.prototype = {
                getstuid : function(){
                    return new Error('抽象类不能调用')
                },
                getstuname: function(){
                    return new Error('抽象类不能调用')
                    
                }
          }
          //声明子类
          var wenstu= function(stuid,stuname){
                this.stuid = stuid
                this.stuname = stuname
          }
          VehicleFactory(wenstu,'student')
          //重写抽象类的方法
          wenstu.prototype.getstuid = function(){
                return this.stuid
          }
          wenstu.prototype.getstuname = function(){
                return this.stuname
          }
          var stu1 = new wenstu('2','jingjing')
          console.log(stu1)
      </script>
  </body>
  </html>